package com.cqie.tes.controller;


import com.cqie.tes.comm.R;
import com.cqie.tes.domain.Course;
import com.cqie.tes.domain.SysMenu;
import com.cqie.tes.domain.qo.SysMenuQo;
import com.cqie.tes.service.SysMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api("菜单管理")
@CrossOrigin
@RestController
@RequestMapping("/sysmenu")
public class SysMenuController {

    @Autowired
    private SysMenuService sysMenuService;

    @PostMapping("/list")
    public R list(SysMenuQo entity){
        return sysMenuService.getList(entity);
    }

    @ApiOperation("新增班级")
    @PostMapping("/add")
    public R add(
            @ApiParam(name = "entity",value = "角色对象") SysMenu entity){
        return sysMenuService.edit(entity);
    }

    @ApiOperation("修改班级")
    @PostMapping("/update")
    public R update(SysMenu entity) {
        return sysMenuService.edit(entity);
    }

    @ApiOperation("根据ID删除")
    @GetMapping("/delete/{id}")
    public R delete(
            @ApiParam(value = "角色ID") @PathVariable("id") Integer id
    ){
        return sysMenuService.deleteById(id);
    }

    @ApiOperation("根据ID批量删除")
    @GetMapping("/batchDelete/{ids}")
    public R batchDelete(
            @ApiParam(value = "角色ID列表:1,2,3") @PathVariable("ids") String ids
    ){
        return sysMenuService.deleteByIds(ids);
    }



    // 下拉菜单结构树
    @PostMapping("/treelist")
    public R treeList(){
        return sysMenuService.treeList();
    }
}
